package com.wlr.study.leetcode;

import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @author lerong.wang
 * @version 1.0.0
 * @description
 * @date 2025/2/24 16:58
 */
public class LeetCode1656 {
    private Map<Integer, String> map;
    private Integer index = 1;

    public LeetCode1656(int n) {
        map = new HashMap<>(n);
    }

    public List<String> insert(int idKey, String value) {
        List<String> ans = new ArrayList<>();
        map.put(idKey, value);
        if (idKey == index) {
            ans.add(map.get(index));
            while (map.containsKey(index + 1)) {
                ans.add(map.get(index + 1));
                index++;
            }
            index++;
        }
        System.out.println(ans);
        return ans;
    }

    public static void main(String[] args) {
        LeetCode1656 leetCode1656 = new LeetCode1656(5);
        leetCode1656.insert(3, "ccccc");
        leetCode1656.insert(1, "aaaaa");
        leetCode1656.insert(2, "bbbbb");
        leetCode1656.insert(5, "eeeee");
        leetCode1656.insert(4, "ddddd");
    }

}